<!-- eslint-disable vue/no-mutating-props -->
<!--
 * @Author: C.
 * @Date: 2023-12-12 18:38:19
-->
<template>
  <CheckboxGroup :model-value="modelValue" v-bind="$attrs" @change="change">
    <!-- <Checkbox label="value1">value1</Checkbox>
    <Checkbox label="value2">value2</Checkbox> -->
    <Checkbox
      v-for="item in getOptions"
      :key="item.value"
      :label="item.value"
      >{{ item.label }}</Checkbox
    >
  </CheckboxGroup>
</template>
<script lang="ts" setup>
// ----------------------------- 第三方引入 -----------------------------
import { computed } from 'vue'

// ----------------------------- hooks -----------------------------

// ----------------------------- 组件 -----------------------------
import CheckboxGroup from '@tuniao/tnui-vue3-uniapp/components/checkbox/src/checkbox-group.vue'
import Checkbox from '@tuniao/tnui-vue3-uniapp/components/checkbox/src/checkbox.vue'
// ----------------------------- 其他引入 -----------------------------

const props = defineProps({
  modelValue: {
    type: [String, Number, Boolean, Array],
  },
  options: {
    type: Array as PropType<Recordable[]>,
    default: () => [],
  },
})
const emits = defineEmits(['update:modelValue'])
//----------------------------- 变量声明区 -----------------------------
const getOptions = computed(() => {
  const { options } = props
  return options || []
})
// ----------------------------- hooks使用区 -----------------------------

// ----------------------------- 钩子函数区 -----------------------------

//  ----------------------------- 自定义方法区 -----------------------------
function change(value: any) {
  emits('update:modelValue', value)
}
</script>
<style lang="less" scoped></style>
